24. Exercise: Adding a JobService
Attention Students: WorkManager is now the preferred way to schedule jobs for Android apps. You can learn more about how to use WorkManager in our course Developing Android Apps with Kotlin.
Ud853 L010 A19 Q Exercise- Adding A JobService 5:17 Re-Edit
Adding a JobService
**Note: ** There is a subtle error in the video above. For the classes JobService and JobParameters you want to use the classes from com.firebase.jobdispatcher.JobService. You DO NOT want to useimport android.app.job.JobService. The latter is used for JobScheduler and remember, we're using FirebaseJobDispatcher because it is compatible with older versions of Android.
This is the first part of a two part exercise. In this exercise you will make a JobService. In the next exercise you will schedule it using FirebaseJobDispatcher.
Exercise Code
SOLUTION:
- Add a new task in `ReminderTasks` for issuing the charging reminder
- Create `WaterReminderFirebaseJobService`, a class which extends `JobService` and runs the charging reminder task off of the main thread